﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Linq.Functions;
using NHibernate.Linq;
using System.Reflection;

namespace WebPattern.Core.Extensions.LINQ
{
    public class RangeContainsGenerator : BaseHqlGeneratorForMethod
    {
        public MemberInfo RangeMin;
        public MemberInfo RangeMax;

        public RangeContainsGenerator() {
            SupportedMethods = new[] { 
                ReflectionHelper.GetMethodDefinition<Range>(x=> x.Contains((short)0)),
                ReflectionHelper.GetMethodDefinition<Range>(x=> x.Contains((int)0)),
                ReflectionHelper.GetMethodDefinition<Range>(x=> x.Contains((long)0)),
                ReflectionHelper.GetMethodDefinition<Range>(x=> x.Contains((float)0)),
                ReflectionHelper.GetMethodDefinition<Range>(x=> x.Contains((double)0)),
                ReflectionHelper.GetMethodDefinition<Range>(x=> x.Contains((decimal)0))
            };

            RangeMin = ReflectionHelper.GetProperty<Range, int>(x => x.Min);
            RangeMax = ReflectionHelper.GetProperty<Range, int>(x => x.Max);
        }
        
        public override NHibernate.Hql.Ast.HqlTreeNode BuildHql(System.Reflection.MethodInfo method, System.Linq.Expressions.Expression targetObject, System.Collections.ObjectModel.ReadOnlyCollection<System.Linq.Expressions.Expression> arguments, NHibernate.Hql.Ast.HqlTreeBuilder treeBuilder, NHibernate.Linq.Visitors.IHqlExpressionVisitor visitor) {
            //treeBuilder.BooleanAnd(treeBuilder.LessThanOrEqual(null, null), treeBuilder.GreaterThanOrEqual(null, null));
            throw new NotImplementedException();
        }
    }
}
